﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcShop.MVC.Extension
{
    public static class Enums
    {
        public static IEnumerable<T> Values<T>(this T en) where T : struct
        {
            if (!typeof(T).IsEnum)
                throw new InvalidOperationException();
            foreach (var x in Enum.GetValues(typeof(T)).Cast<T>())
                yield return x;
        }
    }

}
